﻿using System.Diagnostics;

namespace BackupRestoreSoftwares
{
    public class EasyRAR
    {
        #region Rar - Compress - Extract

        public static void Compress(string rar_file, string path_file)
        {
            // - \" Thêm vào một dấu nháy kép ("")
            var ps = new ProcessStartInfo();
            ps.FileName = @"Rar.exe";
            ps.Arguments = "a -r -ep1 \"" + rar_file + "\" \"" + path_file + "\"";
            //ps.Arguments = "a -r -ep1 \"" + rar_file + "\" \"" + source + "\" -mx=9";
            //               1              2                       3               4
            ps.WindowStyle = ProcessWindowStyle.Hidden;
            Process proc = Process.Start(ps);
            proc.WaitForExit();
        }

        public static void Extract(string rar_file, string path_file)
        {
            var ps = new ProcessStartInfo();
            ps.FileName = @"Rar.exe";
            ps.Arguments = "x -y \"" + rar_file + "\" \"" + path_file + "\"";
            ps.WindowStyle = ProcessWindowStyle.Hidden;
            Process proc = Process.Start(ps);
            proc.WaitForExit();
        }

        #endregion
    }
}